模块:Report
-- @authors Noreplyz -------------------------------------------------------------------------- -- Module:Report Module for report templates. Proofreads user input. This module is invoked using Template:Report spam, Template:Report vandalism, Template:Report profile and Template:Report filter. -- -------------------------------------------------------------------------- local p = {} local fallback = require('Module:Fallback') local switch = require('Module:Report/i18n') -- remove excess or wrongly entered content function trim(s) s = s:match( "^%s*(.-)%s*$" ) return s end function trim_wiki(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("http:%/%/","") s = s:gsub("%.wikia%.com.*", "") return s end function trim_page(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("http:%/%/","") s = s:gsub("^.*%.wikia%.com%/wiki%/","") s = s:gsub("^.*%.wikia%.com%/","") s = s:gsub(" ","_") return s end function trim_user(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("http:%/%/","") s = s:gsub("^.*%.wikia%.com%/wiki%/","") s = s:gsub("^.*%.wikia%.com%/","") s = s:gsub("User:","") s = s:gsub("Special:Contributions%/","") s = s:gsub("Special:Contribs%/","") s = s:gsub(" ","_") s = s:gsub("&","%%26") return s end function trim_reason(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub( "\\\\", "|" ) return s end function trim_id(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("#","") return s end function crosswikilinks(user, wiki) local ippattern = "^%d+%.%d+%.%d+%.%d+$" local cwret = {} cwret+ 1 = '' if (string.match(user, ippattern) nil) then cwret+ 1 = '(.. user .. ' ML • ' else cwret+ 1 = '(.. user .. ' LC • ' end cwret+ 1 = '.. wiki .. '.wikia.com/wiki/Special:CheckUser?user=' .. user .. ' CU • ' .. '.. user .. '&wpPhalanxCheckBlocker=' .. user .. ' Phalanx)' cwret+ 1 = '' return table.concat(cwret) end -- creates the general format of the report -- reportType: string of the type of user (Spammer, Vandal, Profile, Phalanx) function createReport(frame, reportType) local tArgs = frame:getParent() -- all arguments local ret = {} -- the return string local lang = frame:preprocess( " " ) local i18n = fallback._langSwitch(switch, lang) -- check how many total users local numArgs = 0 for key, value in ipairs(tArgs.args) do numArgs = numArgs + 1 end -- report params local wiki = trim_wiki(tArgs.args1 or "") local reason = trim_reason(tArgs.args2 or "") local user = "" local crosswiki = trim(tArgs.args"crosswiki" or "") local socks = trim(tArgs.args"socks" or "") local reporter = tArgs.args- 1 or "" local time = tArgs.argsnumArgs or "" -- report-specific params local skin = "" if reportType "profile" then skin = "?useskin=wikia" end local page = "" local blockId = "" if reportType "Phalanx" then page = trim_page(tArgs.args2 or "") blockId = trim_id(tArgs.args3 or "") reason = tArgs.args4 or "" end -- start report creation ret+ 1 = ' \n' ret+ 1 = '*' .. i18n"wiki" .. ': http://' .. wiki .. '.wikia.com\n' if reportType "Phalanx" then -- Filter problem only ret+ 1 = '*'.. i18n"page" .. ': http://' .. wiki .. '.wikia.com/wiki/' .. page .. '\n' ret+ 1 = '*'.. i18n"blockid" .. ': http://community.wikia.com/wiki/Special:PhalanxStats/' .. blockId .. '\n' else if crosswiki "yes" then ret+ 1 = "*''" .. i18n"cwmsg" .. "\n" end -- Spam, Vandalism or Profile report if numArgs >= 20 then ret+ 1 = ' \n' end for key, value in ipairs(tArgs.args) do if (key >= 3 and key <= (numArgs - 2)) then user = trim_user(value) or "" ret+ 1 = '*' .. i18nreportType .. ': http://' .. wiki .. '.wikia.com/wiki/Special:Contributions/' .. user .. skin .. '' if (reportType "spammer") then ret+ 1 = ' (DelContribs) ' end -- add c/w links if (crosswiki "yes") then ret+ 1 = crosswikilinks(user, wiki) end ret+ 1 = '\n' end end if numArgs >= 20 then ret+ 1 = ' \n' end if socks ~= "" then ret+ 1 = "*".. i18n"spmsg" .. "''\n" for sock in string.gmatch(socks, '(^\n+)') do sock = trim_user(sock) or "" ret+ 1 = '**' .. i18n"sock" .. ': ' .. sock .. '' ret+ 1 = crosswikilinks(sock, wiki) ret+ 1 = '\n' end end end ret+ 1 = '*' .. i18n"reason" .. ': '.. reason ..'\n' ret+ 1 = '*' .. i18n"sig" .. ': -- ' .. reporter .. ' ([talk:'.. reporter .. '|' .. i18n["talk" .. ']]) ' .. time .. '\n' ret+ 1 = ' ' return table.concat(ret) end function p.spam(frame) return createReport(frame, "spammer") end function p.vandalism(frame) return createReport(frame, "vandal") end function p.profile(frame) return createReport(frame, "profile") end function p.filter_problem(frame) return createReport(frame, "Phalanx") end return p --